home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / MPW IIGS Interfaces / CIIGSIncludes / SANE.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-03  |  6.9 KB  |  272 lines  |  [TEXT/MPS ]

  1. /********************************************
  2. ; File: SANE.h
  3. ;
  4. ;
  5. ; Copyright Apple Computer, Inc.1986-90
  6. ; All Rights Reserved
  7. ;
  8. ********************************************/
  9. #ifndef __TYPES__
  10. #include <TYPES.h>
  11. #endif
  12.  
  13. #ifndef __SANE__
  14. #define __SANE__
  15.  
  16.  
  17. /* Decimal Representation Constants */
  18. #define SIGDIGLEN 0x001C
  19. #define DECSTROUTLEN 0x0050
  20.  
  21. /* IEEE defualt environment constant */
  22. #define IEEEDEFAULTENV 0x0000
  23.  
  24. /* Decimal formatting styles */
  25. #define FLOATDECIMAL 0x0000
  26. #define FIXEDDECIMAL 0x0001
  27.  
  28. /* Exceptions */
  29. #define INVALID 0x0001
  30. #define UNDERFLOW 0x0002
  31. #define OVERFLOW 0x0004
  32. #define DIVBYZERO 0x0008
  33. #define INEXACT 0x0010
  34.  
  35. /* Ordering relations */
  36. #define GREATERTHAN 0
  37. #define LESSTHAN 1
  38. #define EQUALTO 2
  39. #define UNORDERED 3
  40. typedef short relop ;
  41.  
  42.  
  43. /* Inquiry classes */
  44. #define SNAN 0
  45. #define QNAN 1
  46. #define INFINITE 2
  47. #define ZERONUM 3
  48. #define NORMALNUM 4
  49. #define DENORMALNUM 5
  50. typedef short numclass ;
  51.  
  52.  
  53. /* Environmental control */
  54.  
  55. /* Rounding directions */
  56. #define TONEAREST 0
  57. #define UPWARD 1
  58. #define DOWNWARD 2
  59. #define TOWARDZERO 3
  60. typedef short rounddir ;
  61.  
  62.  
  63. /* Rounding precisions */
  64. #define EXTPRECISION 0
  65. #define DBLPRECISION 1
  66. #define FLOATPRECISION 2
  67. typedef short roundpre ;
  68.  
  69. typedef short exception;
  70. typedef short environment;
  71. typedef struct decimal {
  72.    short sgn;             /* sign 0 for +, 1 for - */
  73.    short exp;             /* decimal exponent */
  74.    struct {
  75.            unsigned char length, text[SIGDIGLEN], unused;
  76.         } sig;                 /* significant digits */
  77. } decimal;
  78.  
  79. struct decform {
  80.    short style; /* FLOATDECIMAL or FIXEDDECIMAL  */
  81.    short digits;
  82. } ;
  83. typedef struct decform decform;
  84. typedef void (*haltvector)();
  85.  
  86. Extended  fabs ( /* Extended  x */ ) ;
  87.  
  88.  
  89.  
  90. /* Conversions between binary and decimal */
  91. void  num2dec ( /* DecForm  *f,extended  x,Decimal  *d */ ) ;
  92. /* d <-- x according to format f */
  93.  
  94. Extended  dec2num ( /* Decimal  *d */ ) ;
  95. /* Dec2Num <-- d as Extended */
  96.  
  97.  
  98. /* Conversions between decimal formats */
  99. void str2dec ( /* char *s,short *index,Decimal *d,short *validPrefix */ ) ;
  100. /* On input Index is starting index into s.
  101. On output Index is one greater than index of last character of longest numeric substring.
  102. d <-- Decimal rep of longest numeric substring;
  103. validPrefix <-- s, beginning at Index, contains valid numeric string or valid prefix of some numeric string */
  104. void  dec2str ( /* DecForm  *f,Decimal  *d,char  *s */ ) ;
  105. /* s <-- d according to format f */
  106.  
  107.  
  108. /* Arithmetic, auxiliary and elementary functions */
  109. Extended  remainder ( /* Extended  x,Extended  y,short  *quo */ ) ;
  110. /* Remainder <-- x rem y; */
  111. /* quo <-- 7 low-order bits of integer quotient x/y */
  112. /* where -127 < quo < 127 */
  113.  
  114. Extended  sqrt ( /* Extended  x */ ) ;
  115. /* square root */
  116.  
  117. Extended  rint ( /* Extended  x */ ) ;
  118. /* round to integral value */
  119.  
  120. Extended  scalb ( /* short  n,Extended  x */ ) ;
  121. /* scale binary; scalb <-- x * 2^n */
  122.  
  123. Extended  logb ( /* Extended  x */ ) ;
  124. /* binary log: binary exponent of normalized x */
  125.  
  126. Extended  copysign ( /* Extended  x,Extended  y */ ) ;
  127. /* CopySign <-- y with sign of x */
  128.  
  129. Extended  nextfloat ( /* Extended  x,Extended  y */ ) ;
  130. /* next float rep after (float) x in direction of (float) y */
  131.  
  132. Extended  nextdouble ( /* Extended  x,Extended  y */ ) ;
  133. /* next Double rep after (Double) x in direction of (Double) y */
  134.  
  135. Extended  nextextended ( /* Extended  x,Extended  y */ ) ;
  136. /* next extended representation after x in direction of y */
  137.  
  138. Extended  log2 ( /* Extended  x */ ) ;
  139. /* base-2 logarithm */
  140.  
  141. Extended  log ( /* Extended  x */ ) ;
  142. /* base-e logarithm */
  143.  
  144. Extended  log1 ( /* Extended  x */ ) ;
  145. /* log(1 + x) */
  146.  
  147. Extended  exp2 ( /* Extended  x */ ) ;
  148. /* base-2 exponential */
  149.  
  150. Extended  exp ( /* Extended  x */ ) ;
  151. /* base-e exponential */
  152.  
  153. Extended  exp1 ( /* Extended  x */ ) ;
  154. /* exp(x) - 1 */
  155.  
  156. Extended  power ( /* Extended  x,Extended  y */ ) ;
  157. /* general exponential: x ^ y */
  158.  
  159. Extended  ipower ( /* Extended  x,short  i */ ) ;
  160. /* integer exponential: x ^ i */
  161.  
  162. Extended  compound ( /* Extended  r,Extended  n */ ) ;
  163. /* compound: (1 + r) ^ n */
  164.  
  165. Extended  annuity ( /* Extended  r,Extended  n */ ) ;
  166. /* Annuity <-- (1 - (1+r)^(-n)) / r */
  167.  
  168. Extended  tan ( /* Extended  x */ ) ;
  169. /* tangent */
  170.  
  171. Extended  sin ( /* Extended  x */ ) ;
  172. /* Sine */
  173.  
  174. Extended  cos ( /* Extended  x */ ) ;
  175. /* Cosine */
  176.  
  177. Extended  atan ( /* Extended  x */ ) ;
  178. /* Arctangent */
  179.  
  180. Extended  randomx ( /* Extended  *x */ ) ;
  181. /* returns next random number; updates x; */
  182. /* x must be integral, 1 <= x <= 2^31 - 2 */
  183.  
  184.  
  185. /* Inquiry Routines */
  186. numclass  classfloat ( /* Extended  x */ ) ;
  187. /* class of (float) x */
  188.  
  189. numclass  classdouble ( /* Extended  x */ ) ;
  190. /* class of (Double) x */
  191.  
  192. numclass  classcomp ( /* Extended  x */ ) ;
  193. /* class of (Comp) x */
  194.  
  195. numclass  classextended ( /* Extended  x */ ) ;
  196. /* class of x */
  197.  
  198. LongWord  signnum ( /* Extended  x */ ) ;
  199. /* 0 if sign bit clear, 1 if sign bit set */
  200.  
  201.  
  202. /* Environment access routines */
  203. void  setexception ( /* exception  e,long  b */ ) ;
  204. /* clears e flags if b is 0, sets e flags otherwise; may cause halt */
  205.  
  206. long  testexception ( /* exception  e */ ) ;
  207. /* return true if any e flag is set, return false otherwise */
  208.  
  209. void  sethalt ( /* exception  e,long  b */ ) ;
  210. /* set e halt enables if b is true, clear e halt enables otherwise */
  211.  
  212. long  testhalt ( /* exception  e */ ) ;
  213. /* return true if any e halt is enabled, return false otherwise */
  214.  
  215. void  setround ( /* rounddir  r */ ) ;
  216. /* set rounding direction to r */
  217.  
  218. rounddir  getround ( /*  */ ) ;
  219. /* return rounding direction */
  220.  
  221. void  setprecision ( /* roundpre  p */ ) ;
  222. /* sets rnd'n precision to p */
  223.  
  224. roundpre  getprecision ( /*  */ ) ;
  225.  
  226.  
  227. void  setenvironment ( /* environment  e */ ) ;
  228. /* sets SANE environment to e */
  229.  
  230. void  getenvironment ( /* environment  *e */ ) ;
  231. /* e <-- SANE environment */
  232.  
  233. void  procentry ( /* environment  *e */ ) ;
  234. /* e <-- environment;  environment <-- IEEE default env */
  235.  
  236. void  procexit ( /* environment  e */ ) ;
  237. /* temp <-- current exceptions; */
  238. /* SANE environment <-- e; */
  239. /* signals exceptions in temp */
  240.  
  241. haltvector  gethaltvector ( /*  */ ) ;
  242. /* return SANE halt vector */
  243.  
  244. void  sethaltvector ( /* haltvector  v */ ) ;
  245. /* halt vector <-- v */
  246.  
  247.  
  248. /* Comparison routine */
  249. relop  relation ( /* Extended  x,Extended  y */ ) ;
  250. /* return Relation such that "x Relation y" is true */
  251.  
  252.  
  253. /* NaNs and Special Constants */
  254. extended nan( /*  unsigned char c  */ );   /* returns NaN with code c */
  255.  
  256. Extended  inf ( /*  */ ) ;
  257. /* returns infinity */
  258.  
  259. Extended  pi ( /*  */ ) ;
  260. /* returns pi */
  261.  
  262. extern pascal void SANEBootInit() inline(0x010A,dispatcher);
  263. extern pascal void SANEStartUp() inline(0x020A,dispatcher);
  264. extern pascal void SANEShutDown() inline(0x030A,dispatcher);
  265. extern pascal Word SANEVersion() inline(0x040A,dispatcher);
  266. extern pascal void SANEReset() inline(0x050A,dispatcher);
  267. extern pascal Word SANEStatus() inline(0x060A,dispatcher);
  268. extern pascal void SANEFP816() inline(0x090A,dispatcher);
  269. extern pascal void SANEDecStr816() inline(0x0A0A,dispatcher);
  270. extern pascal void SANEElems816() inline(0x0B0A,dispatcher);
  271. #endif
  272.